package interpreter.builtin.functions;

import java.math.BigDecimal;
import java.math.BigInteger;
import java.util.List;

import math.exact.Complex;
import interpreter.Callable;

public class RealPredicate implements Callable {

	@Override
	public Object call(List<Object> arguments) {
		Object arg = arguments.get(0);
		if (arg instanceof Complex) {
			Complex exact = (Complex) arg;
			return exact.getImag().getNumerator().equals(BigInteger.ZERO);
		}
		if (arg instanceof math.inexact.Complex) {
			math.inexact.Complex inexact = (math.inexact.Complex) arg;
			return inexact.getImag().equals(BigDecimal.ZERO);
		}
		return false;
	}

}
